home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 1 / Gold Medal Software Volume 1 (Gold Medal) (1994).iso / prog / tpwprog7.arj / CLICKER.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-07-02  |  1.6 KB  |  76 lines

  1. { clicker.pas -- Demonstrate "subclassing" with objects }
  2.  
  3. program Clicker;
  4.  
  5. uses WinTypes, WinProcs, WObjects;
  6.  
  7. const
  8.  
  9.   id_Button = 100;
  10.  
  11. type
  12.  
  13.   PClickButton = ^TClickButton;
  14.   TClickButton = object(TButton)
  15.     procedure DefNotificationProc(var Msg: TMessage); virtual;
  16.   end;
  17.  
  18.   ClickerApplication = object(TApplication)
  19.     procedure InitMainWindow; virtual;
  20.   end;
  21.  
  22.   PClickerWindow = ^ClickerWindow;
  23.   ClickerWindow = object(TWindow)
  24.     constructor Init(AParent: PWindowsObject; ATitle: PChar);
  25.   end;
  26.  
  27.  
  28. { TClickButton }
  29.  
  30. procedure TClickButton.DefNotificationProc(var Msg: TMessage);
  31. begin
  32.   MessageBeep(0);
  33.   TButton.DefNotificationProc(Msg)
  34. end;
  35.  
  36. { ClickerApplication }
  37.  
  38. {- Initialize ClickerApplication object's window }
  39. procedure ClickerApplication.InitMainWindow;
  40. begin
  41.   MainWindow := New(PClickerWindow, Init(nil, 'DefNotification Demo'))
  42. end;
  43.  
  44.  
  45. { ClickerWindow }
  46.  
  47. {- Construct ClickerWindow object }
  48. constructor ClickerWindow.Init(AParent: PWindowsObject; ATitle: PChar);
  49. var
  50.   AControl: PControl;
  51. begin
  52.   TWindow.Init(AParent, ATitle);
  53.   with Attr do
  54.   begin
  55.     X := 10; Y := 10; W := 300; H := 200
  56.   end;
  57.   AControl := New(PClickButton, Init(@Self, id_Button, 'Click Me',
  58.     100, 100, 100, 40, true))
  59. end;
  60.  
  61. var
  62.  
  63.   ClickerApp: ClickerApplication;
  64.  
  65. begin
  66.   ClickerApp.Init('ClickerApp');
  67.   ClickerApp.Run;
  68.   ClickerApp.Done
  69. end.
  70.  
  71.  
  72. {--------------------------------------------------------------
  73.   Copyright (c) 1991 by Tom Swan. All rights reserved.
  74.   Revision 1.00    Date: 5/11/1991
  75. ---------------------------------------------------------------}
  76.